<template>
  <div class="container">
    <div class="row">
      <el-table
        class="listTable"
        v-loading="listLoading"
        :data="list"
        border
        fit
        highlight-current-row
        style="width: 100%;"
      >
        <el-table-column label="视频记录编号" width="120">
          <template slot-scope="{row}">
            <span>{{ row.videoPlayId }}</span>
          </template>
        </el-table-column>
        <el-table-column label="视频名称" align="center">
          <template slot-scope="{row}">
            <span>{{ row.videoName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="视频播放时间（min）" align="center">
          <template slot-scope="{row}">
            <span>{{ row.videoPlayTime }}</span>
          </template>
        </el-table-column>
        <el-table-column label="视频播放地址" align="center">
          <template slot-scope="{row}">
            <span>{{ row.videoShowUrl }}</span>
          </template>
        </el-table-column>
        <el-table-column label="更新时间" align="center">
          <template slot-scope="{row}">
            <span>{{ row.updateTime }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" width="300">
          <template slot-scope="{row}">
            <el-button
              type="success"
              icon="el-icon-info"
              size="mini"
              @click="preview(row.videoShowUrl)"
            >视频预览</el-button>
            <el-button
              type="primary"
              icon="el-icon-info"
              size="mini"
              @click="detail(row.videoId)"
            >答题预览</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="footers">
      <el-pagination
        :total="total"
        layout="total, prev, pager, next"
        :page-size="limit"
        :current-page.sync="curPage"
        @current-change="getList($event, id)"
        class="sortStyle"
      />
    </div>
    <div class="backBtn">
      <el-button @click="goback">返回</el-button>
    </div>
    <el-dialog :visible.sync="preShow" title="视频答题预览">
      <div class="row">
        <div class="content">
          <div v-for="item in question" :key="item.id">
            <div class="subTitle">{{item.questionId}}.{{item.questionName}}{{item.answerContent}}</div>
            <span style="color:green">正确答案：{{item.rightAnswer}}</span>
            <div class="selStyle" v-for="item2 in item.questionOption" :key="item2.id">
              {{item2}}
            </div>
          </div>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { videoDetail, testDetail } from "@/api/system/user";
export default {
  components: {
   
  },
  data() {
    return {
      userId: this.$route.query.userId,
      list: [],
      listLoading: false,
      limit: 10,
      total: 0,
      curPage: 1,
      preShow: false,
      question: [],
    }
  },
  created() {
  },
  mounted(){
    this.init(this.userId)
  },
  methods: {
    init(id) {
      this.listLoading = true
      videoDetail(id).then(res => {
        this.listLoading = false
        if (res.code == '200') {
          this.list = res.rows
          this.total = res.total
        } else {
          this.$message({ message: res.msg, type: "error" });
        }
      });
    },
    goback() {
      this.$router.go(-1)
    },
    preview(val) {
      window.open('http://www.xlpx.org.cn/fire' + val)
    },
    detail(vId) {
      this.preShow = true
      testDetail(vId).then(res => {
        if (res.code == '200') {
          this.question = res.data.question
        } else {
          this.$message({ message: res.msg, type: "error" });
        }
      });
    },
    back() {
      this.$router.go(-1)
    },
  }
}
</script>
<style scoped>
  .container {
    padding-left: 26px;
    padding-right: 24px;
    padding-top: 24px;
  }
  .row {
    display:flex;
    padding-bottom: 20px;
  }
  .line {
    height: 1px;
    background: #DCDFE6;
    width: 100%;
    margin-top: 6px;
    margin-bottom: 20px;
  }
  .row .font {
    width: 200px;
    text-align: right;
    margin-right: 20px;
  }
  .row .fonts {
    width: 300px;
    text-align: right;
    margin-right: 20px;
  }
  .flex_row {
    display: flex;
  }
  .footer {
    width: 540px;
    text-align: right;
    margin-top: 40px
  }
  .footers {
    position: absolute;
    right: 26px;
  }
  .backBtn {
    text-align: center;
    margin-top: 100px;
  }
  .stuTop {
    display: flex;
    justify-content: space-between;
  }
  .content {
    
  }
  .subTitle {
    line-height: 40px;
  }
  .selStyle {
    line-height: 40px;
    margin-left: 16px;
  }
  /deep/ .el-dialog__body{
    height: 80vh;
    overflow: auto;
  }
</style>
